import axios from "axios";
/** 封装请求模块 */

/** 设备模块 */
export const deviceApi = axios.create({
  baseURL: "/deviceApi",
  withCredentials: true,
});
/** 用能api */
export const energyApi = axios.create({
  baseURL: "/energyApi",
  withCredentials: true,
});
/** 用能api */
export const statisticsApi = axios.create({
  baseURL: "",
  withCredentials: true,
});
/** 监控api */
export const rtspApi = axios.create({
  baseURL: "/rtspApi",
  withCredentials: true,
});
/** 甘特图菜单列表(环思接口文档) */
export const HSExtendInterface = axios.create({
  baseURL: "/HSExtendInterface",
  withCredentials: true,
});
/**时序图数据列表 */
export const dapingApi = axios.create({
  baseURL: "/dapingApi",
  withCredentials: true,
});
/**首页预计图片 */
export const warnApi = axios.create({
  baseURL: "/dapingApi",
  withCredentials: true,
});
/**首页报警图片 */
export const warnImgApi = axios.create({
  baseURL: "/warnImgApi",
  withCredentials: true,
});
/** 请求拦截器 */
deviceApi.interceptors.request.use(async (config) => {
  return config;
});
/** 用能api请求拦截器 */
const accountId = "";
energyApi.interceptors.request.use(async (config) => {
  return config;
});
/** 用能api响应拦截器 */
energyApi.interceptors.response.use(
  async (response) => {
    return response;
  },
  (error) => {
    return Promise.reject(error);
  }
);

HSExtendInterface.interceptors.request.use(async (config) => {
  config.data = {
    //data: {
    ...config.data,
    //},
    // token: "@#$dsjfld1sa%d#$3%Ds0d9fB",
    // scenesNo: "Quota",
    // uploadId: "admin",
  };
  return config;
});
HSExtendInterface.interceptors.response.use(
  async (response) => {
    return response.data.result;
  },
  (error) => {
    return Promise.reject(error);
  }
);
